package na.learn.java.corepatterns.caching.factory;

import na.learn.java.corepatterns.caching.Cache;
import na.learn.java.corepatterns.caching.Cleaner;

public class SimpleCacheFactory implements AbstractCacheFactory {

	public Cache getInstance(Cleaner cleaner) {
		return getInstance(Thread.currentThread().getName(), cleaner);
	}

	public Cache getInstance(String name, Cleaner cleaner) {
		return buildCache(name, cleaner);
	}

	public Cache getInstance(String name, int maxSize, Cleaner cleaner) {
		return buildCache(name, maxSize, cleaner);
	}

	protected Cache buildCache(String name, Cleaner cleaner) {
		Cache cache = new na.learn.java.corepatterns.caching.LRUCache(name, cleaner);
		return cache;
	}

	protected Cache buildCache(String name, int maxSize, Cleaner cleaner) {
		Cache cache = new na.learn.java.corepatterns.caching.LRUCache(name, maxSize, cleaner);
		return cache;
	}

}
